using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class GunBotTilt:MonoBehaviour {

	[SerializeField]  float tiltScale = 1;

	Mob mob;
	private void Start() {
		mob=GetComponent<Mob>();
	}

	float currentAngle;

	const float maxTiltSpeed = 20;

	private void Update() {
		float newAngle = -mob.rigidbody.velocity.x;
		float deltaAngle = newAngle-currentAngle;
		deltaAngle=Mathf.Clamp(deltaAngle,-maxTiltSpeed*Time.deltaTime,maxTiltSpeed*Time.deltaTime);
		transform.rotation*=((Angle)deltaAngle*tiltScale).quaternion;
		currentAngle=currentAngle+deltaAngle;
	}

}
